#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef pair < int , int > pii;
typedef vector < int > vec;
typedef vector < pii > veg;
typedef long long ll;
typedef double db;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch =='-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 2e5 + 10;

int rt[N],n,a[N];

namespace seg {
    const int N = 1e7 + 10;
    int ndn,ch[N][2];
    int merge(int x,int y) {
	if(!x || !y) return x | y;
	ch[y][0] = merge(ch[x][0],ch[y][0]); ch[y][1] = merge(ch[x][1],ch[y][1]);
	return y;
    }
    void modify(int &x,int &y,int xl,int xr,int l = 1,int r = n) {
	if(l == xl && r == xr) return y = merge(x,y),x = 0,void();
	if(!x) return; if(!y) y = ++ndn; int mid = l + r >> 1;
	if(xr <= mid) modify(ch[x][0],ch[y][0],xl,xr,l,mid); else if(xl > mid) modify(ch[x][1],ch[y][1],xl,xr,mid + 1,r);
	else modify(ch[x][0],ch[y][0],xl,mid,l,mid),modify(ch[x][1],ch[y][1],mid + 1,xr,mid + 1,r);
    }
    void upd(int &x,int pos,int l = 1,int r = n) {
	if(!x) x = ++ndn; if(l == r) return; int mid = l + r >> 1;
	if(pos <= mid) upd(ch[x][0],pos,l,mid); else upd(ch[x][1],pos,mid + 1,r);
    }
    void get(int x,int tg,int l = 1,int r = n) {
	if(!x) return; if(l == r) return a[l] = tg,void(); int mid = l + r >> 1;
	get(ch[x][0],tg,l,mid); get(ch[x][1],tg,mid + 1,r);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    n = in; for(int i = 1;i <= n;i++) a[i] = in,seg :: upd(rt[a[i]],i);
    int m = in;
    while(m--) {
	int l = in,r = in,x = in,y = in; if(x == y) continue;
	seg :: modify(rt[x],rt[y],l,r);
    }
    for(int i = 1;i <= 100;i++) seg :: get(rt[i],i);
    for(int i = 1;i <= n;i++) printf("%d%c",a[i]," \n"[i == n]);
    return 0;
}
